<?php
/**
 * Zend Framework Contribution
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Mwb
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    1.0 Diagram.php 3 mai 2012 Sergio DE VASCONCELOS
 */

require_once('Zend/Mwb/Dom/Abstract.php');

/**
 * MySQL Workbench document
 *
 * @category   Zend
 * @package    Zend_Mwb
 */
class Zend_Mwb_Dom_Diagram extends Zend_Mwb_Dom_Abstract
{
	/**
	 * @var Zend_Mwb_Dom_Layers
	 */
	protected $layers;
	/**
	 * @return Zend_Mwb_Dom_Layers
	 */
	public function getLayers() {
		if (is_null($this->layers)) {
			$this->layers = $this->loadLayers();
		}
		return $this->layers;
	}
	/**
	 * @param Zend_Mwb_Dom_Layers
	 * @return Zend_Mwb_Dom_Diagram
	 */
	public function setLayers($layers) {
		$this->layers = $layers;
		return $this;
	}
	protected function loadLayers() {
		$xpath = new DOMXPath($this->node->ownerDocument);
    	$elements = $xpath->query("value[@key='layers']/value", $this->node);
		return new Zend_Mwb_Dom_Layers($elements, $this);
	}
}
